from PyQt5.QtGui import QMovie
from PyQt5.QtCore import pyqtSignal, Qt, QDir
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QApplication, QLabel, QPushButton
import sys
import qdarkstyle
from U_SetDialog import Set_theme


class Cover(QWidget):
	IsSetTheme_signal = pyqtSignal()
	IsStokes_signal = pyqtSignal()
	IsCalculat_signal = pyqtSignal()
	IsRealsimulation_signal = pyqtSignal()

	def __init__(self, parent=None):
		super(Cover, self).__init__(parent)
		self.setWindowTitle("欢迎使用天空偏振光分布模式仿真与探测系统")
		self.setWindowModality(Qt.WindowModal)
		self.resize(873, 702)
		self.color_back = 0

		self.currentPath = QDir.currentPath()
		self.currentPath = self.currentPath.replace('/', '\\')

		self.QVBoxLayout = QVBoxLayout()
		self.Up_HLayout = QHBoxLayout()
		path = self.currentPath + "/Row.gif"
		self.movie = QMovie(path)
		self.Up_Label = QLabel()
		self.Up_Label.setMovie(self.movie)
		self.Up_Label.setFixedHeight(323)
		self.Up_Label.setFixedWidth(640)
		self.movie.start()
		self.Up_HLayout.addWidget(self.Up_Label)
		self.QVBoxLayout.addLayout(self.Up_HLayout)

		self.Middle_HLayout = QHBoxLayout()

		self.Middle1_Label = QLabel()
		self.Middle1_Label.setFixedWidth(110)
		self.Middle1_Label.setFixedHeight(360)

		self.Middle_HLayout.addWidget(self.Middle1_Label)

		self.Middle_left_VLayout = QVBoxLayout()

		self.Middle_left_up_Label = QLabel()
		self.Middle_left_up_Label.setFixedWidth(200)
		self.Middle_left_up_Label.setFixedHeight(30)
		self.Middle_left_VLayout.addWidget(self.Middle_left_up_Label)

		self.Middle_left_Button = QPushButton("探测")
		self.Middle_left_Button.setFixedWidth(200)
		self.Middle_left_Button.setFixedHeight(200)
		self.Middle_left_Button.setStyleSheet("""
						 QPushButton {font-size: 20pt;
							color: #BDC8E2;
							background-color: #2E3648;
							border: 2px solid rgb(24, 25, 26);
							border-radius: 100px;} 

						QPushButton:hover {	/* 鼠标悬浮在QPushButton上时的状态 */
							background-color: rgb(66, 106, 106);
							border-color:rgb(61, 174, 233);
							}
						QPushButton:pressed { /* 鼠标按压在QPushButton上时的状态 */
							background-color: #35071f;
							border-color:rgb(61, 174, 233);}
						""")
		self.Middle_left_VLayout.addWidget(self.Middle_left_Button)

		self.Middle_left_low_Label = QLabel()
		self.Middle_left_low_Label.setFixedWidth(200)
		self.Middle_left_low_Label.setFixedHeight(100)
		self.Middle_left_VLayout.addWidget(self.Middle_left_low_Label)

		self.Middle_HLayout.addLayout(self.Middle_left_VLayout)

		self.Line_Button = QPushButton()
		self.Line_Button.setFixedWidth(1)
		self.Line_Button.setFixedHeight(360)
		self.Middle_HLayout.addWidget(self.Line_Button)

		self.Middle_right_VLayout = QVBoxLayout()
		self.Middle_right_up_Label = QLabel()
		self.Middle_right_up_Label.setFixedWidth(200)
		self.Middle_right_up_Label.setFixedHeight(30)
		self.Middle_right_VLayout.addWidget(self.Middle_left_up_Label)

		self.Middle_right_Button = QPushButton("仿真")
		self.Middle_right_Button.setFixedWidth(200)
		self.Middle_right_Button.setFixedHeight(200)
		self.Middle_right_Button.setStyleSheet("""
								 QPushButton {font-size: 20pt;
									color: #BDC8E2;
									background-color: #2E3648;
									border: 2px solid rgb(24, 25, 26);
									border-radius: 100px;} 

								QPushButton:hover {	/* 鼠标悬浮在QPushButton上时的状态 */
									background-color: rgb(66, 106, 106);
									border-color:rgb(61, 174, 233);
									}
								QPushButton:pressed { /* 鼠标按压在QPushButton上时的状态 */
									background-color: #35071f;
									border-color:rgb(61, 174, 233);}
								""")
		self.Middle_right_VLayout.addWidget(self.Middle_right_Button)

		self.Middlerightlow_Label = QLabel()
		self.Middlerightlow_Label.setFixedWidth(200)
		self.Middlerightlow_Label.setFixedHeight(100)
		self.Middle_right_VLayout.addWidget(self.Middlerightlow_Label)

		self.Middle_HLayout.addLayout(self.Middle_right_VLayout)

		self.Middle2_Label = QLabel()
		self.Middle2_Label.setFixedWidth(110)
		self.Middle2_Label.setFixedHeight(360)

		self.Middle_HLayout.addWidget(self.Middle2_Label)
		self.QVBoxLayout.addLayout(self.Middle_HLayout)

		self.setLayout(self.QVBoxLayout)

		self.setup_signal()

	def setup_signal(self):
		self.Middle_right_Button.clicked.connect(self.Simulation)
		self.Middle_left_Button.clicked.connect(self.Realtime_Simulation)

	def Simulation(self):
		self.IsCalculat_signal.emit()

	def Realtime_Simulation(self):
		self.IsRealsimulation_signal.emit()


if __name__ == '__main__':
	app = QApplication(sys.argv)
	app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())

	demo = Cover()
	demo.show()
	sys.exit(app.exec_())
